package com.rams.jhms.logging;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

import com.rams.jhms.Config;

public class BaseLogger {
	protected static Logger log;
	
	static {
        log = Logger.getLogger("default");
        String logFile = Config.defLogProps;
        if (logFile != null) {
            DOMConfigurator.configure(logFile);
        }
	}
	
    public static void debug(Object o) {
        if (isLogEnable())
        	log.debug(o);
    }

    public static void debug(Object o, Throwable e) {
        if (isLogEnable())
        	log.debug(o, e);
    }

    public static void warn(Object o) {
        if (isLogEnable())
        	log.warn(o);
    }

    public static void warn(Object o, Throwable e) {
        if (isLogEnable())
        	log.warn(o, e);
    }

    public static void error(Object o) {
        if (isLogEnable()) {
        	log.error(o);
        }
    }
    
    public static void error(Object o, Throwable t) {
    	if (isLogEnable()) {
    		log.error(o, t);
    	}
    }

    public static void fatal(Object o) {
        if (isLogEnable())
        	log.fatal(o);
    }

    public static void fatal(Object o, Throwable e) {
        if (isLogEnable())
        	log.fatal(o, e);
    }

    public static void info(Object o) {
        if (isLogEnable()) {
        	log.info(o);
        }
    }

    public static void info(Object o, Throwable e) {
        if (isLogEnable()) {
        	log.info(o, e);
        }
    }
    
    private static boolean isLogEnable() {
    	return Config.appLogingEnable;
    }

}
